package com.atguigu05.method_more._02args.exer;

/**
 * ClassName: StringConCatTest
 * Package: com.atguigu05.method_more._02args.exer
 * Description:
 *      n个字符串进行拼接，每一个字符串之间使用某字符进行分割，如果没有传入字符串，那么返回空字符串""
 * @Author BuTang
 * @Create 2023/2/28 10:25
 * @Version 1.0
 */
public class StringConCatTest {
    public static void main(String[] args) {
        StringConCatTest str = new StringConCatTest();
        String str1 = str.StringConCat("--","Hello","World");
        System.out.println(str1);
    }
    public String StringConCat(String operator,String...str){
        String result = "";
        for (int i = 0; i < str.length-1; i++) {
            result = result +str[i] +operator;
        }
        result += str[str.length-1];
        return result;
    }
}
